<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    function draw() {
      var ctx = document.getElementById('canvas').getContext('2d')
      ctx.fillRect(0, 0, 150, 150)
      ctx.save()

      ctx.fillStyle = '#09F'
      ctx.fillRect(15, 15, 120, 120)
      ctx.save()

      ctx.fillStyle = '#fff'
      ctx.fillRect(30, 30, 90, 90)

      ctx.restore()
      ctx.fillRect(45, 45, 60, 60)

      ctx.restore()
      ctx.fillRect(60, 60, 30, 30)
    }
  </script>
</head>
<body onload="draw()">
  <canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>